
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:mccounting_text/mccounting_text.dart';

import '../consts.dart';
import '../model/orderVO.dart';

class DisplayCardAmountWidget extends StatelessWidget {
  final bool isEle;
  final OrderVO orderVO;

  const DisplayCardAmountWidget({
    super.key,
    required this.orderVO, required this.isEle,
  });


  @override
  Widget build(BuildContext context) {
    int temp = 0;
    if(isEle){
      temp = orderVO.electricityAmountResult!;
    }else{
      temp = orderVO.waterAmountResult!;
    }

    // int temp = 0;
    // if(isEle){
    //   temp = orderVO.electricityAmount! -orderVO.electricityAmountLastMonth!;
    //   if(temp<0){
    //     if(Consts.NEGATIVE_BILL_CALCULATE_WAY){
    //       temp =0;
    //     }else{
    //       temp = Consts().calculateBillFulSituation(orderVO.electricityAmountLastMonth!, orderVO.electricityAmount!);
    //     }
    //   }
    // }else{
    //   temp = orderVO.waterAmount! -orderVO.waterAmountLastMonth!;
    //   if(temp<0){
    //     if(Consts.NEGATIVE_BILL_CALCULATE_WAY){
    //       temp =0;
    //     }else{
    //       temp = Consts().calculateBillFulSituation(orderVO.waterAmountLastMonth!, orderVO.waterAmount!);
    //     }
    //   }
    // }


    return Stack(
      children: [
        Row(
          children: [
            Container(
                padding:   EdgeInsets.only(left: 20.w,top: 4.h),
                height: 23.h,
                width: 65.w,
                decoration: BoxDecoration(
                    color: isEle ? Colors.green : Colors.blueAccent,
                    borderRadius:
                      BorderRadius.only(topLeft:Radius.circular(20.r),bottomLeft: Radius.circular(20.r))),
                child:   Text(
                  isEle ?'用电量':'用水量',
                  style:   TextStyle(
                      fontSize: 13.sp,
                      fontWeight: FontWeight.w700,
                      color: Colors.black54),
                )),
            Expanded(
              child: Container(
                height: 23.h,
                decoration:   BoxDecoration(
                    color: Colors.white54,
                    borderRadius:
                    BorderRadius.only(topRight:Radius.circular(20.r),bottomRight: Radius.circular(20.r))),
                child: Row(
                  children: [
                    Container(
                        margin:   EdgeInsets.only(
                          left: 5.w,
                        ),
                        child:   Text(
                          '本月:',
                          style: TextStyle(fontSize: 15.sp),
                        )),
                    SizedBox(
                      width: 55.w,
                      child:
                      McCountingText(
                        begin: 0,
                        end: temp.toDouble(),
                        precision: 0,
                        style: TextStyle(fontSize: 18.sp,fontWeight: FontWeight.w600),
                        duration: const Duration(seconds: 1),
                        curve: Curves.fastOutSlowIn,
                      )
                    ),
                      Text(
                      '上月:',
                      style: TextStyle(fontSize: 15.sp),
                    ),
                    McCountingText(
                      begin: 0,
                      end:
                        isEle?
                        (orderVO.electricityAmountLastMonthCalculated).toDouble()
                            :(orderVO.waterAmountLastMonthCalculated).toDouble(),
                      precision: 0,
                      style: TextStyle(fontSize: 18.sp,fontWeight: FontWeight.w600),
                      duration: const Duration(seconds: 1),
                      curve: Curves.fastOutSlowIn,
                    )
                    // Text(
                    //   isEle?
                    //   (orderVO.electricityAmountLastMonthCalculated!).toStringAsFixed(0)
                    //       :(orderVO.waterAmountLastMonthCalculated!).toStringAsFixed(0),
                    //   style:   TextStyle(
                    //       fontSize: 18.sp,
                    //       fontWeight: FontWeight.w600),
                    // ),
                  ],
                ),
              ),
            )
          ],
        ),
        Positioned(
            top: -2.h,
            left: 2.w,
            child: Text(
              isEle? "⚡️":"💧",
              style:   TextStyle(fontSize: 20.sp),
            )),
        Positioned(
            top: 0.h,
            right: 3.w,
            child: Text(
              isEle? "度":"吨",
              style:   TextStyle(fontSize: 16.sp,color: Colors.black38),
            )),
      ],
    );
  }
}
